package com.yjhb.android.sbz.mvp.myrecord;

import com.yjhb.android.sbz.entity.ClockInfo;
import com.yjhb.android.sbz.entity.ClockRecord;
import com.yjhb.android.sbz.entity.ResultSet;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;

/**
 * 创建者 zx
 * 创建时间 2021/1/12 15:38
 */
public class MyRecordPresenter extends ConventionPresenter<MyRecordView> {
    private final String TAG = "MyRecordPresenter";

    @Override
    protected void onDestroy() {

    }

    public MyRecordPresenter(MyRecordView myRecordView) {
        super(myRecordView);
    }


    public void getClockList() {
        HttpTool.request(model.getClockList(20, 1), new HttpObserver<ResultSet<ClockRecord>>() {
            @Override
            public void onResult(ResultSet<ClockRecord> data) {
                if (view != null) {
                    view.onLoad(data.getRecords());
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }

    public void getClockCollection() {
//        if (view != null) {
//            view.onWait("加载中...");
//        }
        HttpTool.request(model.getClockCollection(), new HttpObserver<ClockInfo>() {
            @Override
            public void onResult(ClockInfo data) {
                if (view != null) {
                    view.onSuccess(data);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }
}
